package com.hmdp.ThreadUtil;

import lombok.extern.slf4j.Slf4j;

/**
 *@Author:fengxiaohui
 *@Description:
 *@Date:Create in 3:38 下午 2023/6/5
 *@Modified By:
 */
@Slf4j(topic = "thread01")
public class ThreadInterrDemo {

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            while(true){
                boolean interrupted = Thread.currentThread().isInterrupted();
                if (interrupted){
                    log.debug("被打断了，退出循环");
                    break;
                }
            }
        },"t1");
        t1.start();
        Thread.sleep(1000);
        log.debug("interrupted");
        t1.interrupt();
        System.out.println(ThreadInterrDemo.class);
    }
}
